﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GRTVPluginConsole.Entity;

namespace GRTVPluginConsole.Camera
{
    public class FocusLeaderCamera : AutoCameraEngine
    {
        int viewedSlotId = -1;
        int cameraType;
        bool excludePit;
        public FocusLeaderCamera(int cameraType, bool excludePit)
            : base()
        {
            this.cameraType = cameraType;
            this.excludePit = excludePit;
        }

        public override void DoCheck()
        {
            if (Program.DriverList.Count > 0)
            {
                for (int i = 0; i < Program.DriverList.Count; i++)
                {
                    DriverRank dr = Program.DriverList[i];
                    if (dr != null && (!excludePit || !dr.isInPit) && dr.finishStatus <= 1) {
                        if (viewedSlotId != dr.slotId)
                        {
                            viewedSlotId = dr.slotId;
                            Program.ViewDriver(viewedSlotId, cameraType);
                        }
                        break;
                    }
                }
            }
        }

        public override void Reset()
        {
            viewedSlotId = -1;
        }
    }
}
